package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LightningWarn;
import com.ruoyi.system.service.ILightningWarnService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 雷电预警上报市局-来自lightning_dataController
 * 
 * @author ruoyi
 * @date 2024-11-03
 */
@RestController
@RequestMapping("/system/warn")
public class LightningWarnController extends BaseController
{
    @Autowired
    private ILightningWarnService lightningWarnService;

    /**
     * 查询雷电预警上报市局-来自lightning_data列表
     */
    @PreAuthorize("@ss.hasPermi('system:warn:list')")
    @GetMapping("/list")
    public TableDataInfo list(LightningWarn lightningWarn)
    {
        startPage();
        List<LightningWarn> list = lightningWarnService.selectLightningWarnList(lightningWarn);
        return getDataTable(list);
    }

    /**
     * 导出雷电预警上报市局-来自lightning_data列表
     */
    @PreAuthorize("@ss.hasPermi('system:warn:export')")
    @Log(title = "雷电预警上报市局-来自lightning_data", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LightningWarn lightningWarn)
    {
        List<LightningWarn> list = lightningWarnService.selectLightningWarnList(lightningWarn);
        ExcelUtil<LightningWarn> util = new ExcelUtil<LightningWarn>(LightningWarn.class);
        util.exportExcel(response, list, "雷电预警上报市局-来自lightning_data数据");
    }

    /**
     * 获取雷电预警上报市局-来自lightning_data详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:warn:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(lightningWarnService.selectLightningWarnById(id));
    }

    /**
     * 新增雷电预警上报市局-来自lightning_data
     */
    @PreAuthorize("@ss.hasPermi('system:warn:add')")
    @Log(title = "雷电预警上报市局-来自lightning_data", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LightningWarn lightningWarn)
    {
        return toAjax(lightningWarnService.insertLightningWarn(lightningWarn));
    }

    /**
     * 修改雷电预警上报市局-来自lightning_data
     */
    @PreAuthorize("@ss.hasPermi('system:warn:edit')")
    @Log(title = "雷电预警上报市局-来自lightning_data", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LightningWarn lightningWarn)
    {
        return toAjax(lightningWarnService.updateLightningWarn(lightningWarn));
    }

    /**
     * 删除雷电预警上报市局-来自lightning_data
     */
    @PreAuthorize("@ss.hasPermi('system:warn:remove')")
    @Log(title = "雷电预警上报市局-来自lightning_data", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lightningWarnService.deleteLightningWarnByIds(ids));
    }
}
